﻿@using X.PagedList.Mvc.Core;
@model SuperDumpService.ViewModels.DumpsViewModel

<table class="table table-striped table-word-break">
	<thead>
		<tr>
			<th style="">Dumps</th>
			<th style="">Properties</th>
			<th style="width: 90px;" nowrap>Analyzed at</th>
			@if (Model.UseAutomaticDumpDeletion) {
				<th style="width: 90px;" nowrap>Planned Dump Deletion</th>
			}
		</tr>
	</thead>
	<tbody>
		@foreach (var dump in @Model.Paged.OrderByDescending(dump => dump.DumpInfo.Created)) {
			<tr>
				<td>
					<a href="@SuperDumpService.Helpers.Utility.GetDumpUrl(dump.DumpInfo.Id)">
						@(string.IsNullOrEmpty(dump.DumpInfo.DumpFileName) ? "Empty Dump" : System.IO.Path.GetFileName(dump.DumpInfo.DumpFileName))
					</a>
					<span class="text-muted">(@dump.DumpInfo.BundleId:@dump.DumpInfo.DumpId)</span>
					@if (dump.DumpInfo.Status != SuperDumpService.Models.DumpStatus.Finished) {
						<span>(@dump.DumpInfo.Status)</span>
					}
					@if (dump.Similarities.AboveThresholdSimilarities().Any()) {
						<div><strong>duplicates: </strong><a asp-controller="Home" asp-action="Dumps" asp-route-duplBundleId="@dump.DumpInfo.BundleId" asp-route-duplDumpId="@dump.DumpInfo.DumpId">@dump.Similarities.AboveThresholdSimilarities().Count()</a></div>
					}
				</td>
				<td>
					<ul class="flat">
						@foreach (var customProp in dump.BundleViewModel.CustomProperties) {
							<li>
								<strong>@customProp.Key:</strong>
								<possible-link href="@customProp.Value" is-external="true">@customProp.Value</possible-link>
							</li>
						}
					</ul>
				</td>
				<td nowrap>@dump.DumpInfo.Created.ToString("yyyy-MM-dd HH:mmzzz")</td>
				@if (Model.UseAutomaticDumpDeletion) {
					<td nowrap><partial name="_RetentionTime" model="dump.RetentionViewModel" /></td>
				}
			</tr>}
	</tbody>
</table>

@Html.PagedListPager(Model.Paged, page => Url.Action("Dumps", new {
	page = page,
	searchFilter = ViewData["searchFilter"],
	elasticSearchFilter = ViewData["elasticSearchFilter"],
	duplBundleId = ViewData["duplBundleId"],
	duplDumpId = @ViewData["duplDumpId"]
}))

